import xlwings as xw
import os

app = xw.App(visible=False, add_book=False)
# i = 'taskkill/pid ' + str(app.pid) + ' -t -f'
# os.system(i)

workbook = app.books.open(r'C:\Users\Administrator\Desktop\交易订单(1).xlsx')#连接excel文件



#连接到指定单元格(从两列中找出不同的数据)
sheet = workbook.sheets('交易订单')
rows = sheet.used_range.last_cell.row
a = sheet.range(f'B1:B{rows}').value
b= sheet.range(f'C1:C{rows}').value
list = [y for y in (a+b) if y not in b]
print(list)

#
# column = sheet.used_range.last_cell.column
# print(rows)
# # print(sheet.range('A1:A{rows}').value)
#
# #获取一行的数据
# list = sheet[0,:column].value
# #获取一列的数据
# list1 = sheet.range(f'A1:A{rows}').value
#
#
# rng=xw.Range('A1')
#
#
#
# print(list1)
# # sheet.clear()
# # sheet.range('A1').options(expand='table').value=[[1,2],[3,4]]
#
# # list = sheet.range('A1:B2').value
# # print(list)
# workbook.save()
workbook.close()
app.quit()

#
#
# listabc = ['a','b','c','d','e']
# sheet.range('A1').value=listabc

# list1 = sheet.range('A1:E1').value

#
# workbook.save()

# data_range = workbook.sheets('测试excel').range('A1')
# #写入数据
# data_range.value = [1,2,3]


# print(workbook.name)
#保存
# workbook.save()